﻿package ru.spesit.ads.mailru 
{
	import flash.display.*;
	import flash.events.*;
	import flash.net.*;
	import flash.utils.*;

	/**
	 * Class BottomBar ...
	 * @author Yuriy (Mur4ik) Kulkoff 
	 * @version 0.1
	 * @date 12.07.2009
	 */
	public class BottomBar extends SpesItAds_BottomBar
	{
		private var sLink:String;
		private var barWidth:int;
		
		public function BottomBar(w:int) 
		{
			barWidth = w > 345 ? w : 345;
			addEventListener(Event.ADDED_TO_STAGE, init);
		}
		
		private function init(e:Event):void 
		{
			removeEventListener(Event.ADDED_TO_STAGE, init);
			
			graphics.beginFill(0xFFFFFF);
			graphics.drawRect(0, 0, barWidth, 18);
			graphics.endFill();
			
			if (barWidth < 550) tfInfo.visible = false;
			else tfInfo.x = int( (barWidth - tfInfo.width) * .5 );
			
			//SpesItAds_InfoLinkBtn.x = int(width - 172);
			SpesItAds_AddLinkBtn.stop();
			SpesItAds_AddLinkBtn.buttonMode = true;
			SpesItAds_AddLinkBtn.mouseChildren = false;
			SpesItAds_AddLinkBtn.addEventListener(MouseEvent.CLICK, add_clickHandler);
			SpesItAds_AddLinkBtn.addEventListener(MouseEvent.ROLL_OVER, add_overHandler);
			SpesItAds_AddLinkBtn.addEventListener(MouseEvent.ROLL_OUT, add_outHandler);
			
			SpesItAds_InfoLinkBtn.stop();
			SpesItAds_InfoLinkBtn.buttonMode = true;
			SpesItAds_InfoLinkBtn.mouseChildren = false;
			SpesItAds_InfoLinkBtn.addEventListener(MouseEvent.CLICK, info_clickHandler);
			SpesItAds_InfoLinkBtn.addEventListener(MouseEvent.ROLL_OVER, info_overHandler);
			SpesItAds_InfoLinkBtn.addEventListener(MouseEvent.ROLL_OUT, info_outHandler);
		}
		
		private function add_outHandler(e:MouseEvent):void 
		{
			SpesItAds_AddLinkBtn.gotoAndPlay("__out");
		}
		
		private function add_overHandler(e:MouseEvent):void 
		{
			SpesItAds_AddLinkBtn.gotoAndPlay("__over");
		}
		
		private function add_clickHandler(e:MouseEvent):void 
		{
			navigateToURL( new URLRequest(AdsConfig.adsLink) );
		}
		
		
		private function info_outHandler(e:MouseEvent):void 
		{
			SpesItAds_InfoLinkBtn.gotoAndPlay("__out");
		}
		
		private function info_overHandler(e:MouseEvent):void 
		{
			SpesItAds_InfoLinkBtn.gotoAndPlay("__over");
		}
		
		private function info_clickHandler(e:MouseEvent):void 
		{
			navigateToURL( new URLRequest(AdsConfig.infoLink) );
		}
	}
}